package com.myidis.controller;

import com.myidis.entity.AnalysisIndex;
import com.myidis.entity.AnalysisIndexBySubject;
import com.myidis.entity.AnalysisTheme;
import com.myidis.servlet.CIDIIndexManagementServlet;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/IndexManagement")
@Api(tags = "合成/扩散指数 指标管理接口")
public class CIDIIndexManagementController {
    @Autowired
    private CIDIIndexManagementServlet CIDIIndexManagementServlet;

    @ResponseBody
    @RequestMapping("/subjectList")
    @ApiOperation("分析主题列表")
    public ArrayList<AnalysisTheme> subjectList(){
        return CIDIIndexManagementServlet.list();
    }

    @ResponseBody
    @RequestMapping("/quotaBySubjectList")
    @ApiOperation("备选指标列表")
    public ArrayList<AnalysisIndexBySubject> bySubjectList(){
        return CIDIIndexManagementServlet.bySubjectList();
    }

    @ResponseBody
    @RequestMapping("/addToSubject")
    @ApiOperation("为主题增加一个备选指标")
    public int addToSubject(@RequestBody AnalysisIndexBySubject add){
        return CIDIIndexManagementServlet.addToSubject(add);
    }

    @ResponseBody
    @RequestMapping("/delInSubject")
    @ApiOperation("删除主题内一个指标")
    public int delInSubject(@RequestBody int del){
        return CIDIIndexManagementServlet.deleteInSubject(del);
    }

    @ResponseBody
    @RequestMapping("/quotaByCombinationList")
    @ApiOperation("组合内指标列表")
    public ArrayList<AnalysisIndex> list(){
        return CIDIIndexManagementServlet.byCombinationtList();
    }

    @ResponseBody
    @RequestMapping("/addToCombination")
    @ApiOperation("为组合增加一个指标")
    public int addToCombination(@RequestBody AnalysisIndex add){
        return CIDIIndexManagementServlet.addToCombination(add);
    }

    @ResponseBody
    @RequestMapping("/cha")
    @ApiOperation("改变当前基准指标下某一备选指标的一致性/评价")
    //修改完前端需要弹出提示“当前指标 一致性/评价 已修改, 请修改相应指标组合内的指标构成”
    public int upd(@RequestBody AnalysisIndexBySubject upd){
        return CIDIIndexManagementServlet.update(upd);
    }

    @ResponseBody
    @RequestMapping("/deleteInCombination")
    @ApiOperation("删除组合内一个指标")
    public int deleteInCombination(@RequestBody int del){
        return CIDIIndexManagementServlet.deleteInCombination(del);
    }
}
